﻿var bootstrap = function ($, vgole) {
    "use strict";
    var chartArr = [];
    //排序并设置权限
    function sortAndPower(loginInfo, data) {
        //数组排序
        var sortData = data.sort(function (a, b) {
            if (a.f_sortcode0 < b.f_sortcode0) return -1;
            if (a.f_sortcode0 > b.f_sortcode0) return 1;
            return 0;
        });
        //权限过滤
        var powerData = [];
        $.each(sortData, function (index, itemobj) {
            if (loginInfo.userId == "System") {
                powerData.push(itemobj);
            }
        });
        return powerData;
    }
    function loadDesktop() {
        //问题咨询
        var htmlStr = "";
        htmlStr += '<div class="layui-col-md6 self" style="height:281px;">';
        htmlStr += '    <div class="portal-panel-title self-font">';
        //htmlStr += '        <i class="layui-icon layui-icon-notice"></i>&nbsp;&nbsp;问题咨询';
        htmlStr += '        </i>&nbsp;&nbsp;问题咨询';
        htmlStr += '        <span id="noticemore" class="menu" title="更多"><span class="point"></span><span class="point"></span><span class="point"></span></span>';
        htmlStr += '    </div>';
        htmlStr += '    <div class="portal-panel-content" >';

        var res = new Entities("BP.PM.PMBBSs", "AnswerNo", webUser.No, " RDT DESC ");

        for (var j = 0; j < res.length; j++) {
            if (j > 4) continue;
            var item = res[j];
            htmlStr += '        <div class="vg-msg-line">';
            //if (typeof item.IsRead != undefined && item.IsRead == "0") {
            //    htmlStr += '<img src="images/mail_unread.png"/>';
            //}
            htmlStr += '<a id="' + item.OID +
                'item" href="javascript:OpenLayuiDialog(\'/App/BBS/FrmBBS.htm?OID=' + item.OID + '\',\'在线问答\',window.innerWidth * 0.9, undefined, undefined, true);" title="' + item.Title +
                '" style="text-decoration: none;white-space: nowrap;">' + (item.Title.length > 13 ? item.Title.substr(0, 13) + "..." : item.Title) + '</a>';
            htmlStr += '                <label>' + item.RDT + '</label>';
            htmlStr += '        </div>';
        }
        htmlStr += '    </div>';
        htmlStr += '</div>';
        $("#MList").append(htmlStr);
        $("#noticemore").on('click', function () {
            window.top.vm.openTab("咨询服务", "/App/MasterZiXun/Master.htm");
        });

        //等待回复
        htmlStr = "";
        htmlStr += '<div class="layui-col-md6 self" style="height:281px;">';
        htmlStr += '    <div class="portal-panel-title self-font">';
        //htmlStr += '        <i class="layui-icon layui-icon-chart-screen"></i>&nbsp;&nbsp;等待回复';
        htmlStr += '        </i>&nbsp;&nbsp;等待回复';
        htmlStr += '        <span id="jobspecificationmore" class="menu" title="更多"><span class="point"></span><span class="point"></span><span class="point"></span></span>';
        htmlStr += '    </div>';
        htmlStr += '    <div class="portal-panel-content" >';


        for (var j = 0; j < res.length; j++) {
            if (j > 4) continue;
            var item = res[j];
            htmlStr += '        <div class="vg-msg-line">';
            //if (typeof item.IsRead != undefined && item.IsRead == "0") {
            //    htmlStr += '<img src="images/mail_unread.png"/>';
            //}
            htmlStr += '<a id="' + item.OID +
                'item" href="javascript:OpenLayuiDialog(\'/App/BBS/FrmBBS.htm?OID=' + item.OID + '\',\'在线问答\',window.innerWidth * 0.9, undefined, undefined, true);" title="' + item.Title +
                '" style="text-decoration: none;white-space: nowrap;">' + (item.Title.length > 13 ? item.Title.substr(0, 13) + "..." : item.Title) + '</a>';
            htmlStr += '                <label>' + item.RDT + '</label>';
            htmlStr += '        </div>';
        }
        htmlStr += '    </div>';
        htmlStr += '</div>';
        $("#MList").append(htmlStr);
        $("#jobspecificationmore").on('click', function () {
            window.top.vm.openTab("咨询服务", "/App/MasterZiXun/Master.htm");
        });

        //历史咨询
        htmlStr = "";
        htmlStr += '<div class="layui-col-md6 self" style="height:281px;">';
        htmlStr += '    <div class="portal-panel-title self-font">';
        //htmlStr += '        <i class="layui-icon layui-icon-template"></i>&nbsp;&nbsp;历史咨询';
        htmlStr += '        &nbsp;&nbsp;历史咨询';
        htmlStr += '        <span id="regulationmore" class="menu" title="更多"><span class="point"></span><span class="point"></span><span class="point"></span></span>';
        htmlStr += '    </div>';
        htmlStr += '    <div class="portal-panel-content">';

        for (var j = 0; j < res.length; j++) {
            if (j > 4) continue;
            var item = res[j];
            htmlStr += '        <div class="vg-msg-line">';
            //if (typeof item.IsRead != undefined && item.IsRead == "0") {
            //    htmlStr += '<img src="images/mail_unread.png"/>';
            //}
            htmlStr += '<a id="' + item.OID +
                'item" href="javascript:OpenLayuiDialog(\'/App/BBS/FrmBBS.htm?OID=' + item.OID + '\',\'在线问答\',window.innerWidth * 0.9, undefined, undefined, true);" title="' + item.Title +
                '" style="text-decoration: none;white-space: nowrap;">' + (item.Title.length > 13 ? item.Title.substr(0, 13) + "..." : item.Title) + '</a>';
            htmlStr += '                <label>' + item.RDT + '</label>';
            htmlStr += '        </div>';
        }
        htmlStr += '    </div>';
        htmlStr += '</div>';
        $("#SeMList").append(htmlStr);
        $("#regulationmore").on('click', function () {
            window.top.vm.openTab("咨询服务", "/App/MasterZiXun/Master.htm");
        });

        //历史评审
        htmlStr = "";
        htmlStr += '<div class="layui-col-md6 self" style="height:281px;">';
        htmlStr += '    <div class="portal-panel-title self-font">';
        //htmlStr += '        <i class="layui-icon layui-icon-list"></i>&nbsp;&nbsp;历史评审';
        htmlStr += '        &nbsp;&nbsp;历史评审';
        htmlStr += '        <span id="technicalmaterialmore" class="menu" title="更多"><span class="point"></span><span class="point"></span><span class="point"></span></span>';
        htmlStr += '    </div>';
        htmlStr += '    <div class="portal-panel-content" >';

        var handler = new HttpHandler("BP.PM.AppHandler");
        var res = handler.DoMethodReturnString("HasCheckPrj_Init");
        res = eval("(" + res + ")");
        debugger
        for (var j = 0; j < res.length; j++) {
            if (j > 4) continue;
            var item = res[j];
            htmlStr += '        <div class="vg-msg-line">';
            //if (typeof item.IsRead != undefined && item.IsRead == "0") {
            //    htmlStr += '<img src="images/mail_unread.png"/>';
            //}
            htmlStr += '<a id="' + item.OID +
                'item" href="javascript:window.open(\'/WF/Comm/RefFunc/En.htm?EnName=BP.PM.Data.ND1RptHasCheck&PKVal=' + item.OID + '\',\'' + (item.PrjName.length > 13 ? item.PrjName.substr(0, 13) + "..." : item.PrjName) + '\');" title="' + item.PrjName +
                '" style="text-decoration: none;white-space: nowrap;">' + (item.PrjName.length > 13 ? item.PrjName.substr(0, 13) + "..." : item.PrjName) + '</a>';
            htmlStr += '                <label>' + item.LasterCheckRDT + '</label>';
            htmlStr += '        </div>';
        }
        htmlStr += '    </div>';
        htmlStr += '</div>';
        $("#SeMList").append(htmlStr);
        $("#technicalmaterialmore").on('click', function () {
            window.top.vm.openTab("历史评审", "/WF/Comm/Search.htm?EnsName=BP.PM.Data.ND1RptHasChecks");
        });

    }
    loadDesktop();
}